﻿@model DanaZhangCms.Domain.DbModels.ArticleCategory
@{
    Layout = "~/Areas/SysAdmin/Views/Shared/_Layout.cshtml";
}
@section styles{
    <link href="/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/css/plugins/webuploader/webuploader.css">
    <link href="/css/plugins/blueimp/css/blueimp-gallery.min.css" rel="stylesheet">
    <style>
        .lightBoxGallery img {
            margin: 5px;
            width: 160px;
        }
    </style>
}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑频道信息</h5>

                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal">
                        @Html.HiddenFor(o=>o.Id)
                        <div class="form-group">
                            <label class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-10">
                                <input type="text" value="@Model.Title" name="Title" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片</label>
                            <div class="col-sm-10">
                                <div class="lightBoxGallery" id="lightBoxGallery">
                                    <img id="imgholder" src="@Model.ImgUrl">
                                </div>
                                <div class="uploadbox">
                                    <h3>上传图片</h3>
                                </div>
                                <input type="hidden" name="ImgUrl" id="ImgUrl" value="@Model.ImgUrl" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-10">
                                <input type="text" name="SortId" value="@Model.SortId" class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">频道</label>
                            <div class="col-sm-10">
                                <select class="form-control m-b" name="ChannelId">
                                    @foreach (var item in ViewBag.ChannelsList)
                                    {
                                        <option @(Model.ChannelId==item.Id?"selected=\"selected\"":"" ) selected="selected" value="@item.Id">@item.Name</option>
                                    }


                                </select>

                            </div>

                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">父级节点</label>
                            <div class="col-sm-10">
                                <div id="categorys" class="categorys"></div>

                            </div>
                            @Html.HiddenFor(o => o.ParentId, new { id = "ParentId" })
                        </div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-10">
                                <input type="text" name="Content" value="@Model.Content" class="form-control">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label">SeoTitle</label>
                            <div class="col-sm-10">
                                <input type="text" name="SeoTitle" value="@Model.SeoTitle" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">SeoKeywords</label>
                            <div class="col-sm-10">
                                <input type="text" name="SeoKeywords" value="@Model.SeoKeywords" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">SeoDescription</label>
                            <div class="col-sm-10">
                                <input type="text" name="SeoDescription" value="@Model.SeoDescription" class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <button class="btn btn-white" type="submit">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script src="/js/plugins/webuploader/webuploader.min.js"></script>
    <script src="/js/plugins/treeview/bootstrap-treeview.js"></script>
   
    <script>
        $(function () {
            $.get("/sysadmin/ArticleCategory/CategoryJson", function (data) {
                $("#categorys").treeview({
                    color: "#428bca",
                    data: data,
                    onNodeSelected: function (e, o) {
                        $("#ParentId").val(o.href)
                    }
                });
            });


            var BASE_URL = "/js/plugins/webuploader/";
            var uploader = WebUploader.create({
                auto: true,
                swf: BASE_URL + '/Uploader.swf',
                server: '/sysadmin/tools/upload?sf=true',
                pick: '.uploadbox',
                fileVal: "imgFile",
                extensions: "jpg,jpeg,bmp,png",
                resize: false
            });
            uploader.on('uploadSuccess', function (file, response) {
                if (response.success) {
                    $("#imgholder").attr("src", response.url);
                    $("#ImgUrl").val(response.url);
                    layer.alert('上传成功！')
                } else {
                    layer.alert(response.message);
                }
            });
            uploader.on('uploadError', function (file) {
                layer.alert('上传出错，请刷新页面后重试！')
            });


        });
    </script>
}